package com.yupi.yuojbackendcommon.config;



import com.yupi.yuojbackendcommon.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author FengHuan Wang
 * @Date 2025/3/8 9:11
 * @Version 1.0
 */
@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        //注册自定义拦截器对象
        registry.addInterceptor(loginCheckInterceptor)
                // 排除特定业务接口
                .excludePathPatterns("/captcha/**", "/test/**", "/", "/user/login/**","/function-system/**","/user/register", "/error")
                //排除静态资源
                .excludePathPatterns("*.html", "/images/**", "/error")
                //排除swagger相关
                .excludePathPatterns("/doc.html","/webjars/**", "/swagger-resources", "/swagger-resources/**", "/v3/**", "/favicon.ico", "Mozilla/**")
                .excludePathPatterns("/user/login");
    }
}
